import {
  RepoCompObjectEntity,
  RepoCompVersionEntity,
  RepoCompVersionPageResult,
  RepoCompVersionQueryParam,
} from './types';
import request from '@/utils/request';
import {AxiosPromise} from 'axios';

export function listRepoCompVersionEntityList(queryParams: RepoCompVersionQueryParam): AxiosPromise<RepoCompVersionPageResult> {
  return request({
    url: '/kernel/manager/repository/model/version/page',
    method: 'post',
    data: {
      modelId: queryParams.modelId,
      keyword: queryParams.keyword,
      pageNum: queryParams.pageNum,
      pageSize: queryParams.pageSize
    }
  });
}

export function listRepoCompObjectEntityList(queryParams: RepoCompVersionQueryParam): AxiosPromise<RepoCompObjectEntity[]> {
  return request({
    url: '/kernel/manager/repository/model/version/object/entities',
    method: 'post',
    data: {
      versionId: queryParams.versionId,
      keyword: queryParams.keyword,
      pageNum: queryParams.pageNum,
      pageSize: queryParams.pageSize
    }
  });
}

export function getRepoCompObjectEntity(versionId: string, objectId: string) {
  return request({
    url: '/kernel/manager/repository/model/version/object/entity',
    method: 'post',
    data: {
      versionId: versionId,
      objectId: objectId,
    },
  });
}

export function installRepoCompObjectEntity(modelId: string, versionId: string) {
  return request({
    url: '/kernel/manager/repository/model/version/install',
    method: 'post',
    data: {
      modelId: modelId,
      id: versionId,
    },
  });
}
